package Domain.UserClient;
/**
 *   IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!
 *   this file is copied to the UserClient Project!!!
 *   if you change something copy it to there!!
 */




import java.util.Vector;
import objects.Frm;
import objects.Message;
import objects.Trd;
import objects.User;
/**
 * use getType to get the type of the frame

	and getData to get the data of the frame (need cast)    Vector <Frm> f=(Vector)forumFrame.getData();

	so you should be sure the type is right before you ask for the data
	and maybe surround with try and catch in case of cast exception

	be aware of the different between TYPEMSG and ect. to VECTORMSG (if you ask get message you will get vector )


	their is two type of message that you will get without send a massage first

	TYPEUserPublishMsg   -- if user published a message I will send it to all user if they are in the
							same thread as him you will need to acknowledge (dialog or something) the user
	TYPEFriendPublishMsg  -- if a friend of the user has published a message you will need to acknowledge the user
							at the moment you get this message
 * @author Asaf
 *
 */
public class ForumFrame
{
	public static final int ERRUserNotYourFriend = -8; //the data will be the name of the friend to be added
	public static final int UNKOWNERR = -7;
	public static final int UNINTIALIZE = -6;
	public static final int ERRInvalidTypeOfUSer = -5;
	public static final int ERRMsseageNotFound = -4;
	public static final int ERRThreadNotFound = -3;
	public static final int ERRForumNotFound = -2;
	public static final int ERRUserNotFound = -1;  // in case the msseage that sent will contain more then
													//one user the data will be the name of the name of the user that doesn't found
	public static final int TYPEFORUM = 1;
	public static final int TYPETHREAD = 2;
	public static final int TYPEMESSAGE = 3;
	public static final int VECTORFRM = 4;
	public static final int VECTORTRD = 5;
	public static final int VECTORMSG = 6;
	public static final int VECTORUSER = 7;
	public static final int TYPESECCESS = 8;
	public static final int TYPEUserPublishMsg = 9;
	public static final int TYPEFriendPublishMsg = 10;
	public static final int TYPEManager = 11;
	public static final int TYPEDefaultUser = 12;
	public static final int VECTORFRIENDS = 13;



	int type=UNINTIALIZE;
	Object obj;
	public ForumFrame ()
	{

	}
	public ForumFrame (Frm f)
	{
		type=TYPEFORUM;
		obj=f;
	}


	public ForumFrame (Trd t)
	{
		obj=t;
		type=TYPETHREAD;
	}

	public ForumFrame (Message m)
	{
		obj=m;
		type=TYPEMESSAGE;
	}

	public void setVectorTrd (Vector<Trd> t)
	{
		obj=t;
		type=VECTORTRD;
	}


	public void setVectorFrm (Vector<Frm> f)
	{
		obj=f;
		type=VECTORFRM;
	}

	public void setVectorMsg (Vector<Message> m)
	{
		obj=m;
		type=VECTORMSG;
	}

	public void setVectorUser (Vector<User> u)
	{
		obj=u;
		type=VECTORUSER;
	}
	public void setVectorFriends (Vector<User> u)
	{
		obj=u;
		type=VECTORFRIENDS;
	}
	/**
	 *
	 * @param nameOfUser
	 * @param type 1 for manager 0 for default
	 */
	public void setTypeOfUser(String nameOfUser , int typeOfUser)
	{
		obj=nameOfUser;
		if (typeOfUser==1)
		{
			type=TYPEManager;
		}else if (typeOfUser==0)
		{
			type =TYPEDefaultUser;
		}
		else if(typeOfUser==-1)
			type=ERRUserNotFound;
		else type=UNKOWNERR;
	}


	public void setErr (int typeOfErr)
	{
		obj=null;
		type=typeOfErr;
	}
	public void setErrUserNotFound(String nameOfUser)
	{
		type=ERRUserNotFound;
		obj=nameOfUser;
	}
	public Object getData()
	{
		return obj;
	}
	public int getType()
	{
		return type;
	}
	public void setSeccessOporation()
	{
		type=TYPESECCESS;
	}
	/**
	 *
	 * @param nameOfUser
	 * @param nameOfFrm
	 * @param nameOfThread
	 * the data will be nameofuser;nameOfFrm;nameOfTrd
	 */
	public void setUserPublishedMessage(String nameOfUser,String nameOfFrm,String nameOfThread)
	{
		type=TYPEUserPublishMsg;
		obj=new String(nameOfUser+";"+nameOfFrm+";"+nameOfThread);
	}
	public void setFreindPublishedMessage(String nameOfUser,String nameOfFrm,String nameOfThread)
	{
		type=TYPEFriendPublishMsg;
		obj=new String(nameOfUser+";"+nameOfFrm+";"+nameOfThread);
	}


}
